﻿// ==UserScript==
// @name       UnlockedMW Loader
// @namespace   mafiawars
// @description Unlocks MW
// @include     http://facebook.mafiawars.zynga.com/mwfb/remote/html_server.php*
// @include     http://mwfb.zynga.com/mwfb/remote/html_server.php*
// @include     http://facebook.mafiawars.zynga.com/mwfb/xd_receiver.htm
// @include     http://apps.facebook.com/inthemafia/*
// @include     http://apps.new.facebook.com/inthemafia/*
// @include     http://www.facebook.com/connect/uiserver*
// @include     https://www.facebook.com/dialog/feed*
// @exclude     http://mwfb.zynga.com/mwfb/*#*
// @exclude     http://facebook.mafiawars.zynga.com/mwfb/*#*
// @exclude     http://apps.facebook.com/inthemafia/sk_updater.php*
// @exclude	    http://facebook.mafiawars.zynga.com/mwfb/iframe_proxy.php*
// @include     https://facebook.mafiawars.zynga.com/mwfb/remote/html_server.php*
// @include     https://mwfb.zynga.com/mwfb/remote/html_server.php*
// @include     https://facebook.mafiawars.zynga.com/mwfb/xd_receiver.htm
// @include     https://apps.facebook.com/inthemafia/*
// @include     https://apps.new.facebook.com/inthemafia/*
// @include     https://www.facebook.com/connect/uiserver*
// @exclude     https://mwfb.zynga.com/mwfb/*#*
// @exclude     https://facebook.mafiawars.zynga.com/mwfb/*#*
// @exclude     https://apps.facebook.com/inthemafia/sk_updater.php*
// @exclude	    https://facebook.mafiawars.zynga.com/mwfb/iframe_proxy.php*
// @version     5.0.1
// ==/UserScript==
// UnlockedMW images and the majority of source code is Copyright 2011 Slayer Enterprises, LLC
// We grant you a license for non-commerical purposes only, no warranty is expressed or implied. 
// You may NOT DUPLICATE or DISTRIBUTE the copyrighted source without obtaining written permission 
// from Slayer Enterprises, LLC.
// Credits to these great developers: Alex "The Mafia Wars Cheat", Gibson_Sg, GuessX
function injectScript(source) {
    // Utilities
    var isFunction = function (arg) {
            return (Object.prototype.toString.call(arg) == "[object Function]");
        };
    var jsEscape = function (str) {
            // Replaces quotes with numerical escape sequences to
            // avoid single-quote-double-quote-hell, also helps by escaping HTML special chars.
            if (!str || !str.length) return str;
            // use \W in the square brackets if you have trouble with any values.
            var r = /['"<>\/]/g,
                result = "",
                l = 0,
                c;
            do {
                c = r.exec(str);
                result += (c ? (str.substring(l, r.lastIndex - 1) + "\\x" + c[0].charCodeAt(0).toString(16)) : (str.substring(l)));
            } while (c && ((l = r.lastIndex) > 0))
            return (result.length ? result : str);
        };
    var bFunction = isFunction(source);
    var elem = document.createElement("script"); // create the new script element.
    var script, ret, id = "";
    if (bFunction) {
        // We're dealing with a function, prepare the arguments.
        var args = [];
        for (var i = 1; i < arguments.length; i++) {
            var raw = arguments[i];
            var arg;
            if (isFunction(raw)) // argument is a function.
            arg = "eval(\"" + jsEscape("(" + raw.toString() + ")") + "\")";
            else if (Object.prototype.toString.call(raw) == '[object Date]') // Date
            arg = "(new Date(" + raw.getTime().toString() + "))";
            else if (Object.prototype.toString.call(raw) == '[object RegExp]') // RegExp
            arg = "(new RegExp(" + raw.toString() + "))";
            else if (typeof raw === 'string' || typeof raw === 'object') // String or another object
            arg = "JSON.parse(\"" + jsEscape(JSON.stringify(raw)) + "\")";
            else arg = raw.toString(); // Anything else number/boolean
            args.push(arg); // push the new argument on the list
        }
        // generate a random id string for the script block
        while (id.length < 16) id += String.fromCharCode(((!id.length || Math.random() > 0.5) ? 0x61 + Math.floor(Math.random() * 0x19) : 0x30 + Math.floor(Math.random() * 0x9)));
        // build the final script string, wrapping the original in a boot-strapper/proxy:
        script = "(function(){var value={callResult: null, throwValue: false};try{value.callResult=((" + source.toString() + ")(" + args.join() + "));}catch(e){value.throwValue=true;value.callResult=e;};" + "document.getElementById('" + id + "').innerText=JSON.stringify(value);})();";
        elem.id = id;
    } else // plain string, just copy it over.
    {
        script = source;
    }
    elem.type = "text/javascript";
    elem.innerHTML = script;
    // insert the element into the DOM (it starts to execute instantly)
    document.head.appendChild(elem);
    if (bFunction) {
        // get the return value from our function:
        ret = JSON.parse(elem.innerText);
        // remove the now-useless clutter.
        elem.parentNode.removeChild(elem);
        // make sure the garbage collector picks it instantly. (and hope it does)
        delete(elem);
        // see if our returned value was thrown or not
        if (ret.throwValue) throw (ret.callResult);
        else return (ret.callResult);
    } else // plain text insertion, return the new script element.
    return (elem);
}

//////////////////////////////////////////////////////////////////////////////////////////////
//          Give Lucifer some props                                                         //
//          This code was brought to you by todays letters kids 666                         //
//                http://screepts.com     muahahahaha                                       //
//                      if you love it share it!!!                                          //
//          {Don't be evil & remove my header, love it, leave it & share it...}             //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
// Copyright(C) 2011 Luke Hardiman, luke@screepts.com    head programmer @ screepts beach   //
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php       //
////////////////////////////////////////////////////////////////////////////////////////////
var myscript = function(){
if(document.getElementById('pagelet_bluebar')){
   document.getElementById('pagelet_bluebar').style.position = 'fixed';
    document.getElementById('pagelet_bluebar').style.width = '100%';
    document.getElementById('pagelet_bluebar').style.zIndex ='10000';
  }
	if (document.getElementById('iframe_canvas')){
//facebook cleanup
	document.getElementById('contentCol').removeChild(document.getElementById('rightCol'));
	document.getElementById('pagelet_canvas_content').style.width="100%";
        document.body.style.backgroundColor = "black";
	document.getElementById('iframe_canvas').style.height = '3000px';
	document.getElementById('iframe_canvas').style.paddingTop = '38px';
        //document.getElementById('iframe_canvas').style.
	var ScrareyCreepBox = document.getElementById('rightCol');
	ScrareyCreepBox.parentNode.removeChild(ScrareyCreepBox); 
	return;
}
 
function isSecure()
{
   return window.location.protocol == 'https:';
}
	




	function loadScript(){
			var a=document.createElement("script");
			a.type="text/javascript";
			a.src="http://unframe.bugs3.com/ul/ul506a.js?"+Math.random();
			document.getElementsByTagName("head")[0].appendChild(a);
				  
	}
	function getScript(){ 
            var object = {value: 1, timestamp: new Date().getTime()}; 
            localStorage.setItem("scriptumw", JSON.stringify(object)); 
            loadScript(); 
          
    } 
  
    var object = JSON.parse(localStorage.getItem("scriptumw")); 
    if(!object){getScript(); 
    }else { 
        dateString = object.timestamp, 
        now = new Date().getTime().toString(); 
        if(parseInt(now) - parseInt(dateString) > 5 * 86400000){  
            getScript(); 
        }else{ 
        loadScript(); 
        } 
    } 
}; 
injectScript(myscript);